<script setup>
import * as mars3d from "mars3d"

export let map // mars3d.Map三维地图对象
export let graphicLayer // 矢量图层对象
export const eventTarget = new mars3d.BaseClass()

// 初始化地图业务，生命周期钩子函数（必须）,框架在地图初始化完成后自动调用该函数
export function onMounted(mapInstance) {
  map = mapInstance // 记录map

  // 创建矢量数据图层
  graphicLayer = new mars3d.layer.GraphicLayer()
  map.addLayer(graphicLayer)


  addDemoGraphic6(graphicLayer)
}

// 释放当前地图业务的生命周期函数,具体项目中时必须写onMounted的反向操作（如解绑事件、对象销毁、变量置空）
export function onUnmounted() {
  map = null

  graphicLayer.remove()
  graphicLayer = null
}




// 也可以直接使用ConeTrack对象
function addDemoGraphic6(graphicLayer) {
  const point = new mars3d.LngLatPoint(116.504297, 30.924326, 900000)

  // 添加模型
  const graphicModel = new mars3d.graphic.ModelEntity({
    position: point,
    style: {
      url: "https://data.mars3d.cn/gltf/mars/feiji.glb",
      scale: 1,
      minimumPixelSize: 50,
      pitch: 90,
      roll: 90,
      heading: 90
    },
    attr: { remark: "示例6" }
  })
  graphicLayer.addGraphic(graphicModel)

  // 效果1
  const pointQY = point.clone()
  pointQY.alt = pointQY.alt / 2

  const graphic = new mars3d.graphic.CylinderEntity({
    position: pointQY,
    style: {
      length: point.alt,
      topRadius: 0.0,
      bottomRadius: 200000,
      materialType: mars3d.MaterialType.CylinderWave,
      materialOptions: {
        color: "#ffff00",
        repeat: 30.0,
        thickness: 0.2
      }
    }
  })
  graphicLayer.addGraphic(graphic) // 还可以另外一种写法: graphic.addTo(graphicLayer)
}


</script>

<template>

</template>

<style scoped>

</style>